<?php

$cash_advances_for_form = array();
$i=1;
foreach( $this->cash_advance_items as $cash_advance )
{
	$desc_name = "desc$i";
	$amt_name = "amt$i";
	
	$cash_advances_for_form[$desc_name] = $cash_advance['description'];
	$cash_advances_for_form[$amt_name] = $cash_advance['amt'];
	                                   
	$i++;
}

// make new form and validate with fields from previous step
$cash_advance_form = new CashAdvanceItemsForm();
$cash_advance_action_URL = $this->url(array('controller'=>'index', 'action'=>'kseditcashadvances'));

$cash_advance_form->populate($cash_advances_for_form);
$cash_advance_form->setAction( $cash_advance_action_URL );

// render and echo the form
echo $cash_advance_form->render_with_template("cashadvancestable.xhtml");

 ?>